import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-06-29
 * Time: 22:28
 */
public class Test6 {

    public static List<List<Integer>> threeSum(int[] num) {
        List<List<Integer>> ret = new ArrayList<>();
        Arrays.sort(num);
        for(int i = 0; i < num.length;) {
            int target = -num[i];
            int left = i+1,right = num.length-1;
            while(left < right) {
                int sum = num[left]+num[right];
                if(sum == target) {
                    ret.add(new ArrayList<>(Arrays.asList(num[left],num[right],num[i])));
                    left++;
                    right--;
                while(left < right && num[left-1] == num[left]) {
                    left++;
                }
                while(left < right && num[right+1] == num[right]) {
                    right--;
                }
                }else if(sum < target) {
                    left++;
                }else {
                    right--;
                }
            }
            i++;
            while(i < num.length && num[i-1] == num[i]) {
                i++;
            }
        }

        return ret;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        List<List<Integer>> ret = threeSum(num);
        System.out.println(ret);
    }
}
